package org.sdfc.model.attr

import com.documentum.fc.common.IDfId
import com.documentum.fc.common.IDfTime

import org.sdfc.model.MutableTypedObject
import org.sdfc.model.TypedObject

/** An attribute repeating of the data model.
 */
trait RepeatingAttribute[+T] extends Attribute[T] {
  
  /** AttrType of the Attribute, refined to be a RepeatingAttrType. */
  override def attrType : RepeatingAttrType[T]
  
  /** True, by definition of this. */
  final def isRepeating = true
  
  
  /** The generic form for this, refined to be of the repeating kind. */
  val genericForm : RepeatingAttributeGenericForm[T]
  
}


/** An attribute repeating/boolean of the data model.
 */
trait RepeatingBooleanAttribute extends RepeatingAttribute[Boolean] {
  attr =>
  
  /** repeating/boolean AttrType, by definition of this. */
  final def attrType = RepeatingBooleanAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[Boolean] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setBooleanValues(attr, src.getBooleanValues(attr))
  }
  
}

/** An attribute repeating/int of the data model.
 */
trait RepeatingIntAttribute extends RepeatingAttribute[Int] {
  attr =>
  
  /** repeating/int AttrType, by definition of this. */
  final def attrType = RepeatingIntAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[Int] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setIntValues(attr, src.getIntValues(attr))
  }
  
}

/** An attribute repeating/string of the data model.
 */
trait RepeatingStringAttribute extends RepeatingAttribute[String] {
  attr =>
  
  /** repeating/string AttrType, by definition of this. */
  final def attrType = RepeatingStringAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[String] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setStringValues(attr, src.getStringValues(attr))
  }
  
}

/** An attribute repeating/id of the data model.
 */
trait RepeatingIdAttribute extends RepeatingAttribute[IDfId] {
  attr =>
  
  /** repeating/id AttrType, by definition of this. */
  final def attrType = RepeatingIdAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[IDfId] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setIdValues(attr, src.getIdValues(attr))
  }
  
}

/** An attribute repeating/time of the data model.
 */
trait RepeatingTimeAttribute extends RepeatingAttribute[IDfTime] {
  attr =>
  
  /** repeating/time AttrType, by definition of this. */
  final def attrType = RepeatingTimeAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[IDfTime] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setTimeValues(attr, src.getTimeValues(attr))
  }
  
}

/** An attribute repeating/double of the data model.
 */
trait RepeatingDoubleAttribute extends RepeatingAttribute[Double] {
  attr =>
  
  /** repeating/double AttrType, by definition of this. */
  final def attrType = RepeatingDoubleAttrType
  
  
  /** The generic form for this. */
  final val genericForm = new RepeatingAttributeGenericForm[Double] {
    def copy(src : TypedObject, tgt : MutableTypedObject) : Unit =
      tgt.setDoubleValues(attr, src.getDoubleValues(attr))
  }
  
}